using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;

public class WeaponReward : MonoBehaviour
{
    public GameObject[] weaponArr;
    public GameObject getBuffEffect;

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            int index = Random.Range(0, weaponArr.Length);
            PlayerTank playerTank = other.GetComponent<PlayerTank>();
            playerTank.ChangeWeapon(weaponArr[index]);
            
            //特效
            GameObject buff = Instantiate(getBuffEffect, this.transform.position, this.transform.rotation);
            AudioSource audioSource = buff.GetComponent<AudioSource>();
            audioSource.volume = GameDataManager.Instance.musicData.soundValue;
            audioSource.mute = !GameDataManager.Instance.musicData.isOpenSound;    
            Destroy(gameObject);
        }
    }
}